{include file='public/header' /}

<body>

<div class="x-nav">

  <span class="layui-breadcrumb">

      <a href="">首页</a>

      <a href="">检测报告管理</a>

      <a><cite>检测报告列表</cite></a>
  </span>

  <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">

      <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>

  </a>

</div>





<div class="x-body">



    <table class="layui-hide" id="test" lay-filter="test"></table>

    <input id="currid" type="hidden" name="curr" value="1">

   

</div>





<script type="text/html" id="toolbarDemo">

      <div class="layui-form-item"> 

        <form class="layui-form" action="" lay-filter="search">

          <div class="layui-input-inline">

                  <select name="status">
                      <option value="">全部状态</option>

                      <option value="1">待审核</option>

                      <option value="2">审核通过</option>

                      <option value="3">审核未通过</option>

                  </select>

          </div>



          <div class="layui-input-inline">

                  <select name="staffid">
                      <option value="">全部员工</option>
                      {foreach $stafflist as $x}
                      <option value="{$x.id}">{$x.name}</option>
                      {/foreach}
                  </select>

          </div>




          <div class="layui-input-inline" style="width:20%;">
            <input type="text" class="layui-input test" name="create_time"  autocomplete="off" placeholder="时间段搜索" id="test1">
          </div>



           <input type="text"  placeholder="请输入搜索内容" autocomplete="off" class="layui-btn layui-btn-primary" name="keywords">

            <div class="layui-inline">
              <button class="layui-btn"  lay-event="searchBarFunc"><i class="layui-icon">&#xe615;</i></button>
            </div>  
        </form>
      </div>
</script>



<script type="text/html" id="barDemo">

  <div class="layui-btn-group">

      {if $qxarr['look']}
      <button type="button" class="layui-btn" lay-event="look">查看</button>
      {/if}

      {if $qxarr['shenhe']}
      {{#  if(d.status == 1){ }}
      <button type="button" class="layui-btn" lay-event="shenhe">审核</button>
      {{#  } }}

      {{#  if(d.status > 1){ }}
      <button type="button" class="layui-btn" lay-event="shenhe">重新审核</button>
      {{#  } }}
      {/if}
     

  </div>




</script>



<script type="text/html" id="status">

    {{#  if(d.status == 1){ }}

      <span class="layui-btn layui-btn-normal layui-btn-xs">待审核</span>

    {{#  } }}


    {{#  if(d.status == 2){ }}

      <span class="layui-btn  layui-btn-xs">已通过</span>

    {{#  } }}



    {{#  if(d.status == 3){ }}

      <span class="layui-btn  layui-btn-danger layui-btn-xs">未通过</span>

    {{#  } }}


</script>




<script type="text/html" id="h5url">

      <span style="color:#009688;">https://zjjth5.ccicgdauto.com/?oid={{d.oid}}</span>

</script>



<script type="text/html" id="uid">

    {{#  if(d.userinfo){ }}

      {{d.userinfo.name}}
     
    {{#  } }}

</script>



<script type="text/html" id="staffid">

    {{#  if(d.staffinfo){ }}

      {{d.staffinfo.name}}
     
    {{#  } }}

</script>




<style type="text/css">

  /*{# 设置table每一行的height #}*/

  .layui-table-cell {

   height: 50px;

   line-height: 50px;

  }

 </style>





<script>

layui.use(['table','laydate'], function(){

  var table = layui.table

  ,form = layui.form
  ,laydate = layui.laydate;

        laydate.render({
          elem: '#test1'
          ,type: 'datetime'
          ,range: true
        });

  //第一个实例

  table.render({

    elem: '#test'

    ,height:'full-100'

    ,title:'检测报告列表'

    ,url: "{:url('gList')}" //数据接口

    ,page: true //开启分页

    ,limit:30

    ,toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板

    ,cols: [[ //表头

       {field: 'code', title: '关联订单'}

      ,{field: 'uid', title: '收件用户',templet: '#uid'}

      ,{field: 'staffid', title: '提交员工',templet: '#staffid'}

      ,{field: 'brand', title: '品牌车型'}

      ,{field: 'car_num', title: '车牌号码'}

      ,{field: 'status', title: '审核结果',templet: '#status'}

      ,{field: 'url', title: '检测报告链接',templet: '#h5url',width:300}

      ,{field: 'create_time', title: '生成时间'}

      ,{fixed: 'right', title:'操作', toolbar: '#barDemo'}

    ]]
     ,done: function(res, curr, count){
      
      $('#currid').val(curr);
      //得到当前页码
      console.log(curr); 

       laydate.render({
              elem: '#test1'
              ,type: 'datetime'
              ,range: true
            });
    
  }

  });



  //监听行工具事件

  table.on('tool(test)', function(obj){

    var data = obj.data;

    //console.log(obj)

    if(obj.event === 'look'){
        layer.open({
        type: 2,
        title: '查看检测报告信息',
        maxmin: true,
        shadeClose: true, //点击遮罩关闭层
        area : ['750px' , '90%'],
        content: 'https://zjjth5.xsh618.com?oid='+data.oid
      });
    }else if(obj.event === 'shenhe'){
            var curr = $('#currid').val();
            layer.confirm('检测报告审核', {
                    btn: ['审核通过','审核失败'] //按钮
                  , btn1:function(){
                      $.post("{:url('shenhe')}",{id:data.id,status:2},function (res) {
                          if(res == 1){

                                var data = form.val('search');
              
                                table.reload('test',{
                                    url: "{:url('gList')}",

                                    page: {
                                      curr: curr 
                                    }

                                   ,where: data
                                   ,done: function(res, curr, count){
                                      form.val('search', data);
                                      $('#currid').val(curr);
                                       //日期范围
                                      laydate.render({
                                        elem: '#test1'
                                        ,type: 'datetime'
                                        ,range: true
                                      });

                                   }
                                })


                               layer.msg('操作成功', {icon: 1});
                          }else {
                              layer.msg('请稍后重试！',{icon:0,time:1000});
                          }

                      })

                  },  btn2:function(){
                       
                       $.post("{:url('shenhe')}",{id:data.id,status:3},function (res) {
                          if(res == 1){
                               
                               var data = form.val('search');
              
                                table.reload('test',{
                                    url: "{:url('gList')}",

                                    page: {
                                      curr: curr 
                                    }

                                   ,where: data
                                   ,done: function(res, curr, count){
                                      form.val('search', data);
                                      $('#currid').val(curr);
                                       //日期范围
                                        laydate.render({
                                          elem: '#test1'
                                          ,type: 'datetime'
                                          ,range: true
                                        });

                                   }
                                })


                               layer.msg('操作成功', {icon: 1});

                          }else {
                              layer.msg('请稍后重试！',{icon:0,time:1000});
                          }

                      })

                  }

            });


    }

  });



 //头工具栏事件

  table.on('toolbar(test)', function(obj){

       if(obj.event === 'searchBarFunc'){

              var data = form.val('search');
            
              table.reload('test',{
                  url: "{:url('gList')}",

                  page: {
                    curr: 1 //重新从第 1 页开始
                  }

                 ,where: data
                 ,done: function(res, curr, count){
                    form.val('search', data);
                    $('#currid').val(curr);
                    //得到当前页码
                    console.log(curr); 


                     //日期范围
                      laydate.render({
                        elem: '#test1'
                        ,type: 'datetime'
                        ,range: true
                      });

                 }
              })


        }

  });



  

});

</script>











</body>

</html>